$().ready(function () {
  // 在键盘按下并释放及提交后验证提交表单
  $("#login").validate({
    rules: {
      username: {
        required: true,
        minlength: 2,
      },
      password: {
        required: true,
        minlength: 5,
        maxlength: 10,
      },
      confirm_password: {
        required: true,
        minlength: 5,
        maxlength: 10,
        equalTo: "#password",
      },
    },
    messages: {
      username: {
        required: "请输入用户名",
        minlength: "用户名必需由两个字符组成",
      },
      password: {
        required: "请输入密码",
        minlength: "密码长度不能小于 5 个字符",
      },
      confirm_password: {
        required: "请输入密码",
        minlength: "密码长度不能小于 5 个字符",
        equalTo: "两次密码输入不一致",
      },   
    },
      //表单验证通过的提交事件
      submitHandler (form) {
        parent.location.href = './list.html'
      } 
  });
});
